import grails.test.*

class BabyServiceTests extends GrailsUnitTestCase {
    def babyService = new BabyService()
    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testPaln2Task(){
      def model = initDate()
      def baby = model.baby
      def planCount = Plan.count()
      println "planCount:" + planCount
      babyService.paln2Task(baby)
      def tasks = Task.list()
      println "task size: " + tasks.size()
      tasks.each {
        println "${it.title} ${it.content}"
      }
    }

    def initDate(){
      def person = new Person(
              username:'liguoqiang',
              userRealName:'liguoqiang',
              passwd:'123',
              enabled: true,
              stage : new Integer(20015),
              email:'serviceany@gmail.com',
              emailShow:true,
      )

      person.save()
      println person.errors
      def baby = new Baby(
              nickName:'qiaoqiao',
              realName:'lihuixin',
              birth:(new Date()) - 15,
              gender:Boolean.TRUE,
              person:person,
      )

      baby.save()
      println baby.errors

      def model = [:]
      model.person = person
      model.baby = baby
      return model
    }
}
